EOD = new Object();

Ext.define('BalanceSheet', {
	extend : 'Ext.data.Model',
	fields : [ {
		name : 'name',
		type : 'string'
	}, {
		name : 'balance',
		type : 'float'
	} ]
});

Ext.define('PendingInstrument', {
	extend : 'Ext.data.Model',
	fields : [ {
		name : 'dealType',
		type : 'string'
	}, {
		name : 'dealCode',
		type : 'string'
	}, {
		name : 'insCode',
		type : 'string'
	}, {
		name : 'status',
		type : 'string'
	} ]
});

Ext.define('PendingCollateral', {
	extend : 'Ext.data.Model',
	fields : [ {
		name : 'dealCode',
		type : 'string'
	}, {
		name : 'dealValue',
		type : 'string'
	}, {
		name : 'issuer',
		type : 'string'
	}, {
		name : 'valueDate',
		type : 'date',
		dateFormat : 'd/m/Y'
	} ]
});

Ext.define('PendingInvestment', {
	extend : 'Ext.data.Model',
	fields : [ {
		name : 'investCode',
		type : 'string'
	}, {
		name : 'custCode',
		type : 'string'
	}, {
		name : 'amount',
		type : 'float'
	}, {
		name : 'reqDate',
		type : 'date',
		dateFormat : 'd/m/Y'
	} ]
});

Ext.define('PendingRedemption', {
	extend : 'Ext.data.Model',
	fields : [ {
		name : 'redCode',
		type : 'string'
	}, {
		name : 'custCode',
		type : 'string'
	}, {
		name : 'type',
		type : 'string'
	}, {
		name : 'amount',
		type : 'float'
	}, {
		name : 'reqDate',
		type : 'date',
		dateFormat : 'd/m/Y'
	} ]
});

Ext.define('PendingDeal', {
	extend : 'Ext.data.Model',
	fields : [ {
		name : 'dealNo',
		type : 'string'
	}, {
		name : 'type',
		type : 'string'
	}, {
		name : 'amount',
		type : 'float'
	}, {
		name : 'createdUser',
		type : 'string'
	}, {
		name : 'createdDate',
		type : 'date',
		dateFormat : 'd/m/Y'
	} ]
});

Ext.define('PendingCashReq', {
	extend : 'Ext.data.Model',
	fields : [ {
		name : 'reqNo',
		type : 'string'
	}, {
		name : 'amount',
		type : 'string'
	}, {
		name : 'reqDate',
		type : 'date',
		dateFormat : 'd/m/Y'
	} ]
});

Ext.define('FloatingRateInsrument', {
	extend : 'Ext.data.Model',
	fields : [ {
		name : 'dealCode',
		type : 'string'
	}, {
		name : 'insType',
		type : 'string'
	}, {
		name : 'insCode',
		type : 'string'
	}, {
		name : 'issuer',
		type : 'string'
	} ]
});

var fundCustBalStore = new Ext.data.Store({
	model : 'BalanceSheet',
	storeId : 'eodFundCustBalStore'
});

var fundIssuerBalStore = new Ext.data.Store({
	model : 'BalanceSheet',
	storeId : 'eodFundIssuerBalStore'
});

var receivePendingInsStore = new Ext.data.Store({
	model : 'PendingInstrument',
	storeId : 'eodReceivePendingInsStore'
});

var issuePendingInsStore = new Ext.data.Store({
	model : 'PendingInstrument',
	storeId : 'eodIssuePendingInsStore'
});

var pendingInvestStore = new Ext.data.Store({
	model : 'PendingInvestment',
	storeId : 'eodPendingInvestStore'
});

var pendingRedempStore = new Ext.data.Store({
	model : 'PendingRedemption',
	storeId : 'eodPendingRedempStore'
});

var pendingDealStore = new Ext.data.Store({
	model : 'PendingDeal',
	storeId : 'eodPendingDealStore'
});

var pendingPaymentStore = new Ext.data.Store({
	model : 'PendingCashReq',
	storeId : 'eodPendingPaymentStore'
});

var pendingReceiptStore = new Ext.data.Store({
	model : 'PendingCashReq',
	storeId : 'eodPendingReceiptStore'
});

var floatingRatePendingStore = new Ext.data.Store({
	model : 'FloatingRateInsrument',
	storeId : 'eodFlotingRatePendingStore'
});

var repoPendingCollatStore = new Ext.data.Store({
	model : 'PendingCollateral',
	storeId : 'repoPendCollatStore'
});

var revRepoPendingCollatStore = new Ext.data.Store({
	model : 'PendingCollateral',
	storeId : 'revRepoPendCollatStore'
});

EOD.getFieldSet1 = function() {

	var funds = Ext.create('Ext.data.Store', {
		fields : [ 'id', 'fundName', 'fundCode', {
			name : 'updateDate',
			type : 'date',
			dateFormat : 'c'
		}, 'portfolio', 'unitValue' ],
		storeId : 'eodFundsStore'
	});

	var finalFieldSet = Ext.create('Ext.form.FieldSet', {
		title : 'Funds',
		// layout: 'fit',
		items : [ Ext.create('Ext.panel.Panel', {
			// autoScroll: true,
			// layout: 'fit',
			items : [ Ext.create('Ext.grid.Panel', {
				store : funds,
				id : 'eodFundPanel',
				autoScroll : true,
				columns : [ {
					text : 'Fund',
					dataIndex : 'fundName',
					width : 150,
					flex : 2
				}, {
					text : 'Code',
					dataIndex : 'fundCode',
					width : 100,
					flex : 1
				}, {
					text : 'Last Valuation',
					dataIndex : 'updateDate',
					xtype : 'datecolumn',
					format : 'd-m-Y',
					flex : 1,
					align : 'center'
				}, {
					xtype : 'actioncolumn',
					text : 'Analyze',
					flex : 1,
					align : 'center',
					items : [ {
						icon : 'images/Go_1.jpg',
						tooltip : 'Edit',
						handler : function(grid, rowIndex, colIndex) {
							var rec = grid.getStore().getAt(rowIndex);
							var valueDate = Ext.Date.add(rec.get('updateDate'), Ext.Date.DAY, 1);
							if (Ext.Date.parse(Ext.util.Format.date(rec.get('updateDate')), 'm/d/Y') >= Ext.Date.parse(Ext.util.Format.date(new Date()), 'm/d/Y')) {
								Ext.Msg.alert('Error', 'Fund is upto Date.');
							} else {
								var pnl = Ext.ComponentQuery.query('#eodFundPanel')[0];
								pnl.setLoading('<p style="color:green;font:bold 18px Arial,Helvetica,sans-serif;">Analyzing the Fund...</p>', true);
								var progBar = Ext.ComponentQuery.query('#eodProressBar')[0];
								progBar.show();
								Ext.ComponentQuery.query('#eodFundNameLbl')[0].setText(rec.get('fundName'));
								Ext.ComponentQuery.query('#eodFundBalLbl')[0].setText('Current Portfolio Value: ' + rec.get('portfolio'));
								Ext.ComponentQuery.query('#eodFundUnitValueLbl')[0].setText('Current Unit Value: ' + rec.get('unitValue'));

								loadSample(rec.get('id'), valueDate);
								Ext.ComponentQuery.query('#eodCheckListField')[0].show();
								Ext.ComponentQuery.query('#eodContinueBtn')[0].enable();
							}
						}
					} ]
				} ],
				height : 240,
				// width : 500,
				listeners : {
					itemclick : function(dv, record, item, index, e) {

					}
				}
			})

			]
		}),

		Ext.create('Ext.ProgressBar', {
			id : 'eodProressBar',
			flex : 1,
			hidden : true
		}) ]

	});

	return finalFieldSet;
};

EOD.getFieldSet2 = function() {

	var finalFieldSet = Ext.create('Ext.form.FieldSet', {
		title : 'Check List',
		id : 'eodCheckListField',
		hidden : true,
		defaults : {
			anchor : '100%'
		},
		items : [ {
			xtype : 'fieldset',
			layout : 'vbox',
			items : [ {
				xtype : 'label',
				id : 'eodFundNameLbl',
				style : 'font-weight:800;margin:0px 0 0px 0px;'
			}, {
				xtype : 'label',
				id : 'eodFundBalLbl',
				// text : 'Cash Remaining in the Fund: 100000',
				style : 'font-weight:550;margin:5px 0 0px 0px;'
			}, {
				xtype : 'label',
				id : 'eodFundUnitValueLbl',
				// text : 'Cash Remaining in the Fund: 100000',
				style : 'font-weight:550;margin:5px 0 0px 0px;'
			} ]
		}, Ext.create('Ext.grid.Panel', {
			store : fundCustBalStore,
			style : 'margin-top:20px;',
			title : 'Customer Balances',
			// bodyStyle: 'background:#99CCFF; padding:10px;',
			columns : [ {
				text : 'Customer',
				dataIndex : 'name',
				flex : 2
			}, {
				text : 'Balance',
				dataIndex : 'balance',
				flex : 1
			} ],
			// height : 300,
			width : 450,
			bbar : [ '->' ],
			listeners : {
				itemclick : function(dv, record, item, index, e) {
					alert('aaa');
				}
			}

		}), Ext.create('Ext.grid.Panel', {
			store : fundIssuerBalStore,
			style : 'margin-top:20px;',
			title : 'Issuer Balances',
			// bodyStyle: 'background:#99CCFF; padding:10px;',
			columns : [ {
				text : 'Issuer',
				dataIndex : 'name',
				flex : 2
			}, {
				text : 'Balance',
				dataIndex : 'balance',
				flex : 1
			} ],
			// height : 300,
			width : 450,
			bbar : [ '->' ]
		}), Ext.create('Ext.grid.Panel', {
			store : receivePendingInsStore,
			style : 'margin-top:20px;',
			title : 'Pending Instrumnets (Not Received)',
			// bodyStyle: 'background:#99CCFF; padding:10px;',
			columns : [ {
				text : 'Deal Type',
				dataIndex : 'dealType',
				flex : 1
			}, {
				text : 'Deal Code',
				dataIndex : 'dealCode',
				flex : 1
			}, {
				text : 'Instrument',
				dataIndex : 'insCode',
				flex : 1
			}, {
				text : 'Current Status',
				dataIndex : 'status',
				flex : 2
			} ],
			// height : 300,
			width : 450,
			bbar : [ '->' ]
		}), Ext.create('Ext.grid.Panel', {
			store : issuePendingInsStore,
			style : 'margin-top:20px;',
			title : 'Pending Instrumnets (Not Issued)',
			// bodyStyle: 'background:#99CCFF; padding:10px;',
			columns : [ {
				text : 'Deal Type',
				dataIndex : 'dealType',
				flex : 1
			}, {
				text : 'Deal Code',
				dataIndex : 'dealCode',
				flex : 1
			}, {
				text : 'Instrument',
				dataIndex : 'insCode',
				flex : 1
			}, {
				text : 'Current Status',
				dataIndex : 'status',
				flex : 2
			} ],
			// height : 300,
			width : 450,
			bbar : [ '->' ]
		}), Ext.create('Ext.grid.Panel', {
			store : pendingInvestStore,
			style : 'margin-top:20px;',
			title : 'Pending Investments',
			// bodyStyle: 'background:#99CCFF; padding:10px;',
			columns : [ {
				text : 'Invest Code',
				dataIndex : 'investCode',
				flex : 1
			}, {
				text : 'Customer Code',
				dataIndex : 'custCode',
				flex : 1
			}, {
				text : 'Amount',
				dataIndex : 'amount',
				flex : 1
			}, {
				xtype : 'datecolumn',
				format : 'd/m/Y',
				text : 'Requested Date',
				dataIndex : 'reqDate',
				flex : 1
			} ],
			// height : 300,
			width : 450,
			bbar : [ '->' ]
		}), Ext.create('Ext.grid.Panel', {
			store : pendingRedempStore,
			style : 'margin-top:20px;',
			title : 'Pending Redemptions',
			// bodyStyle: 'background:#99CCFF; padding:10px;',
			columns : [ {
				text : 'Redemption Code',
				dataIndex : 'redCode',
				flex : 1
			}, {
				text : 'Customer Code',
				dataIndex : 'custCode',
				flex : 1
			}, {
				text : 'Redemption Type',
				dataIndex : 'type',
				flex : 1
			}, {
				text : 'Amount',
				dataIndex : 'amount',
				flex : 1
			}, {
				xtype : 'datecolumn',
				format : 'd/m/Y',
				text : 'Expected',
				dataIndex : 'reqDate',
				flex : 1
			} ],
			// height : 300,
			width : 450,
			bbar : [ '->' ]
		}), Ext.create('Ext.grid.Panel', {
			store : pendingDealStore,
			style : 'margin-top:20px;',
			title : 'Pending Deals',
			// bodyStyle: 'background:#99CCFF; padding:10px;',
			columns : [ {
				text : 'Type',
				dataIndex : 'type',
				flex : 1
			}, {
				text : 'Code',
				dataIndex : 'dealNo',
				flex : 1
			}, {
				text : 'Amount',
				dataIndex : 'amount',
				flex : 1
			}, {
				text : 'Created By',
				dataIndex : 'createdUser',
				flex : 1
			}, {
				xtype : 'datecolumn',
				format : 'd/m/Y',
				text : 'Created Date',
				dataIndex : 'createdDate',
				flex : 1
			} ],
			// height : 300,
			width : 450,
			bbar : [ '->' ]
		}), Ext.create('Ext.grid.Panel', {
			store : pendingPaymentStore,
			style : 'margin-top:20px;',
			title : 'Pending Payments',
			// bodyStyle: 'background:#99CCFF; padding:10px;',
			columns : [ {
				text : 'Payment No',
				dataIndex : 'reqNo',
				flex : 1
			}, {
				text : 'Amount',
				dataIndex : 'amount',
				flex : 1
			}, {
				xtype : 'datecolumn',
				format : 'd/m/Y',
				text : 'Requested Date',
				dataIndex : 'reqDate',
				flex : 1
			} ],
			// height : 300,
			width : 450,
			bbar : [ '->' ]
		}), Ext.create('Ext.grid.Panel', {
			store : pendingReceiptStore,
			style : 'margin-top:20px;',
			title : 'Pending Receipts',
			// bodyStyle: 'background:#99CCFF; padding:10px;',
			columns : [ {
				text : 'Receipt No',
				dataIndex : 'reqNo',
				flex : 1
			}, {
				text : 'Amount',
				dataIndex : 'amount',
				flex : 1
			}, {
				xtype : 'datecolumn',
				format : 'd/m/Y',
				text : 'Requested Date',
				dataIndex : 'reqDate',
				flex : 1
			} ],
			// height : 300,
			width : 450,
			bbar : [ '->' ]
		}), Ext.create('Ext.grid.Panel', {
			store : repoPendingCollatStore,
			style : 'margin-top:20px;',
			title : 'Pending Collaterals - REPO Deals',
			columns : [ {
				text : 'Deal Code',
				dataIndex : 'dealCode',
				flex : 1
			}, {
				text : 'Deal Value',
				dataIndex : 'dealValue',
				flex : 1
			}, {
				text : 'Issuer',
				dataIndex : 'issuer',
				flex : 1
			}, {
				xtype : 'datecolumn',
				format : 'd/m/Y',
				text : 'Starting Date',
				dataIndex : 'valueDate',
				flex : 1
			} ],
			// height : 300,
			width : 450,
			bbar : [ '->' ]
		}), Ext.create('Ext.grid.Panel', {
			store : revRepoPendingCollatStore,
			style : 'margin-top:20px;',
			title : 'Pending Collaterals - Reverse REPO Deals',
			columns : [ {
				text : 'Deal Code',
				dataIndex : 'dealCode',
				flex : 1
			}, {
				text : 'Deal Value',
				dataIndex : 'dealValue',
				flex : 1
			}, {
				text : 'Issuer',
				dataIndex : 'issuer',
				flex : 1
			}, {
				xtype : 'datecolumn',
				format : 'd/m/Y',
				text : 'Starting Date',
				dataIndex : 'valueDate',
				flex : 1
			} ],
			// height : 300,
			width : 450,
			bbar : [ '->' ]
		}), Ext.create('Ext.grid.Panel', {
			store : floatingRatePendingStore,
			style : 'margin-top:20px;',
			title : 'Floating Rates Pending Instrumnts',
			// bodyStyle: 'background:#99CCFF; padding:10px;',
			columns : [ {
				text : 'Deal Code',
				dataIndex : 'dealCode',
				flex : 1
			}, {
				text : 'Instrument Type',
				dataIndex : 'insType',
				flex : 1
			}, {
				text : 'Instrument',
				dataIndex : 'insCode',
				flex : 1
			}, {
				text : 'Issuer',
				dataIndex : 'issuer',
				flex : 1
			} ],
			// height : 300,
			width : 450,
			bbar : [ '->' ]
		}) ]
	});
	return finalFieldSet;
};

EOD.getFieldSet3 = function() {

	var finalFieldSet = Ext.create('Ext.form.FieldSet', {

		items : [ Ext.create('Ext.Button', {
			text : 'CONTINUE',
			id : 'eodContinueBtn',
			border : 2,
			disabled : true,
			style : {
				borderColor : 'blue',
				borderStyle : 'solid',
				fontSize : '12px',
				fontFamily : 'Arial,Helvetica,sans-serif',
				fontWeight : '550,'
			},
			handler : function() {
				finalFieldSet.setLoading('Running EOD...');
				var fundStore = Ext.data.StoreManager.lookup('eodFundsStore');
				var fundName = Ext.ComponentQuery.query('#eodFundNameLbl')[0].text;
				var selectedRec = fundStore.getAt(fundStore.find('fundName', fundName));
				var fundId = selectedRec.get('id');
				var valueDate = Ext.Date.add(selectedRec.get('updateDate'), Ext.Date.DAY, 1);

				Ext.Ajax.request({
					url : 'runEod.action',
					params : {
						queryOne : fundId,
						valueDate : Ext.util.Format.date(valueDate)
					},
					success : function(response) {
						Ext.Msg.alert('Day End Completed for the fund: ' + fundId);
						Ext.data.StoreManager.lookup('eodFundCustBalStore').removeAll();
						Ext.data.StoreManager.lookup('eodFundIssuerBalStore').removeAll();
						Ext.data.StoreManager.lookup('eodReceivePendingInsStore').removeAll();
						Ext.data.StoreManager.lookup('eodIssuePendingInsStore').removeAll();
						Ext.data.StoreManager.lookup('eodPendingInvestStore').removeAll();
						Ext.data.StoreManager.lookup('eodPendingRedempStore').removeAll();
						Ext.data.StoreManager.lookup('eodPendingDealStore').removeAll();
						Ext.data.StoreManager.lookup('eodPendingPaymentStore').removeAll();
						Ext.data.StoreManager.lookup('eodPendingReceiptStore').removeAll();
						Ext.data.StoreManager.lookup('eodFlotingRatePendingStore').removeAll();
						Ext.data.StoreManager.lookup('repoPendCollatStore').removeAll();
						Ext.data.StoreManager.lookup('revRepoPendCollatStore').removeAll();
						Ext.ComponentQuery.query('#eodCheckListField')[0].hide();
						Ext.ComponentQuery.query('#eodContinueBtn')[0].disable();
						Ext.data.StoreManager.lookup('eodFundsStore').removeAll();
						Ext.Ajax.request({
							url : 'getDayEndFunds.action',
							success : function(response) {
								var obj = Ext.decode(response.responseText);
								Ext.data.StoreManager.lookup('eodFundsStore').loadRawData(obj.fundList);
								finalFieldSet.setLoading(false);
							},
							failure : function() {
								finalFieldSet.setLoading(false);
								Ext.Msg.alert('Error', 'Failed to load Fund List');
							}
						});

					},
					failure : function(response) {
						Ext.Msg.alert('Error!', 'Failed to load Issuer Balances : ' + response);
						finalFieldSet.setLoading(false);
					}
				});
			}
		}) ]
	});

	return finalFieldSet;
};

loadSample = function(fundId, valueDate) {
	var progBar = Ext.ComponentQuery.query('#eodProressBar')[0];
	progBar.show();

	progBar.updateProgress((0.08), 'Query Customer Balance...');

	Ext.Ajax.request({
		url : 'pendingMoneyTrans.action',
		params : {
			queryOne : fundId,
			queryTwo : 'CUS',
			valueDate : Ext.util.Format.date(valueDate)
		},
		success : function(response) {
			progBar.updateProgress((0.12), 'Query Customer Balance...');
			var custBalObj = Ext.decode(response.responseText);
			fundCustBalStore.removeAll();
			var custBalArray = custBalObj.resultString.split(";");
			var i;
			for (i = 0; i < custBalArray.length; i++) {
				if (custBalArray[i].replace(/^\s+|\s+$/g, '') != "") {
					var custBal = custBalArray[i].split(',');
					var custBalRec = Ext.create('BalanceSheet', {
						name : custBal[0],
						balance : custBal[1]
					});
					fundCustBalStore.add(custBalRec);
				}
			}
			progBar.updateProgress((0.16), 'Query Issuer Balance...');

			Ext.Ajax.request({
				url : 'pendingMoneyTrans.action',
				params : {
					queryOne : fundId,
					queryTwo : 'ISU',
					valueDate : Ext.util.Format.date(valueDate)
				},
				success : function(response) {
					progBar.updateProgress((0.2), 'Query Issuer Balance...');
					var issueBalObj = Ext.decode(response.responseText);
					issuePendingInsStore.removeAll();
					var issueBalArray = issueBalObj.resultString.split(";");
					var i;
					for (i = 0; i < issueBalArray.length; i++) {
						if (issueBalArray[i].replace(/^\s+|\s+$/g, '') != "") {
							var issueBal = issueBalArray[i].split(',');
							var issueBalRec = Ext.create('BalanceSheet', {
								name : issueBal[0],
								balance : issueBal[1]
							});
							fundIssuerBalStore.add(issueBalRec);
						}
					}
					progBar.updateProgress((0.24), 'Query Pending Receive Instruments...');
					Ext.Ajax.request({
						url : 'pendingReceiveIns.action',
						params : {
							queryOne : fundId,
							valueDate : Ext.util.Format.date(valueDate)
						},
						success : function(response) {
							progBar.updateProgress((0.28), 'Query Pending Receive Instruments...');
							var recInsObj = Ext.decode(response.responseText);
							receivePendingInsStore.removeAll();
							var recInsArray = recInsObj.resultString.split(";");
							var i;
							for (i = 0; i < recInsArray.length; i++) {
								if (recInsArray[i].replace(/^\s+|\s+$/g, '') != "") {
									var recIns = recInsArray[i].split(',');
									var recInsRec = Ext.create('PendingInstrument', {
										dealType : recIns[0],
										dealCode : recIns[1],
										insCode : recIns[2],
										status : recIns[3]
									});
									receivePendingInsStore.add(recInsRec);
								}
							}
							progBar.updateProgress((0.32), 'Query Pending Issue Instruments...');

							Ext.Ajax.request({
								url : 'pendingIssueIns.action',
								params : {
									queryOne : fundId,
									valueDate : Ext.util.Format.date(valueDate)
								},
								success : function(response) {
									progBar.updateProgress((0.36), 'Query Pending Issue Instruments...');
									var recInsObj = Ext.decode(response.responseText);
									issuePendingInsStore.removeAll();
									var recInsArray = recInsObj.resultString.split(";");
									var i;
									for (i = 0; i < recInsArray.length; i++) {
										if (recInsArray[i].replace(/^\s+|\s+$/g, '') != "") {
											var recIns = recInsArray[i].split(',');
											var recInsRec = Ext.create('PendingInstrument', {
												dealType : recIns[0],
												dealCode : recIns[1],
												insCode : recIns[2],
												status : recIns[3]
											});
											issuePendingInsStore.add(recInsRec);
										}
									}
									progBar.updateProgress((0.40), 'Query Pending Investments...');
									Ext.Ajax.request({
										url : 'pendingInvests.action',
										params : {
											queryOne : fundId,
											valueDate : Ext.util.Format.date(valueDate)
										},
										success : function(response) {
											progBar.updateProgress((0.44), 'Query Pending Investments...');
											var recInsObj = Ext.decode(response.responseText);
											pendingInvestStore.removeAll();
											var recInsArray = recInsObj.resultString.split(";");
											var i;
											for (i = 0; i < recInsArray.length; i++) {
												if (recInsArray[i].replace(/^\s+|\s+$/g, '') != "") {
													var recIns = recInsArray[i].split(',');
													var recInsRec = Ext.create('PendingInvestment', {
														investCode : recIns[0],
														custCode : recIns[1],
														amount : recIns[2],
														reqDate : recIns[3]
													});
													pendingInvestStore.add(recInsRec);
												}
											}
											progBar.updateProgress((0.48), 'Query Pending Redemptions...');
											Ext.Ajax.request({
												url : 'pendingRedemps.action',
												params : {
													queryOne : fundId,
													valueDate : Ext.util.Format.date(valueDate)
												},
												success : function(response) {
													progBar.updateProgress((0.52), 'Query Pending Redemptions...');
													var recInsObj = Ext.decode(response.responseText);
													pendingRedempStore.removeAll();
													var recInsArray = recInsObj.resultString.split(";");
													var i;
													for (i = 0; i < recInsArray.length; i++) {
														if (recInsArray[i].replace(/^\s+|\s+$/g, '') != "") {
															var recIns = recInsArray[i].split(',');
															var recInsRec = Ext.create('PendingRedemption', {
																redCode : recIns[0],
																custCode : recIns[1],
																type : recIns[2],
																amount : recIns[3],
																reqDate : recIns[4]
															});
															pendingRedempStore.add(recInsRec);
														}
													}
													progBar.updateProgress((0.56), 'Query Pending Deals...');
													Ext.Ajax.request({
														url : 'pendingDeals.action',
														params : {
															queryOne : fundId,
															valueDate : Ext.util.Format.date(valueDate)
														},
														success : function(response) {
															progBar.updateProgress((0.60), 'Query Pending Deals...');
															var recInsObj = Ext.decode(response.responseText);
															pendingDealStore.removeAll();
															var recInsArray = recInsObj.resultString.split(";");
															var i;
															for (i = 0; i < recInsArray.length; i++) {
																if (recInsArray[i].replace(/^\s+|\s+$/g, '') != "") {
																	var recIns = recInsArray[i].split(',');
																	var recInsRec = Ext.create('PendingDeal', {
																		type : recIns[0],
																		dealNo : recIns[1],
																		amount : recIns[2],
																		createdUser : recIns[3],
																		createdDate : recIns[4]
																	});
																	pendingDealStore.add(recInsRec);
																}
															}
															progBar.updateProgress((0.64), 'Query Pending Payments...');
															Ext.Ajax.request({
																url : 'pendingPayments.action',
																params : {
																	queryOne : fundId,
																	valueDate : Ext.util.Format.date(valueDate)
																},
																success : function(response) {
																	progBar.updateProgress((0.68), 'Query Pending Payments...');
																	var recInsObj = Ext.decode(response.responseText);
																	pendingPaymentStore.removeAll();
																	var recInsArray = recInsObj.resultString.split(";");
																	var i;
																	for (i = 0; i < recInsArray.length; i++) {
																		if (recInsArray[i].replace(/^\s+|\s+$/g, '') != "") {
																			var recIns = recInsArray[i].split(',');
																			var recInsRec = Ext.create('PendingCashReq', {
																				reqNo : recIns[0],
																				amount : recIns[1],
																				reqDate : recIns[2]
																			});
																			pendingPaymentStore.add(recInsRec);
																		}
																	}
																	progBar.updateProgress((0.72), 'Query Pending Receipts...');
																	Ext.Ajax.request({
																		url : 'pendingReceipts.action',
																		params : {
																			queryOne : fundId,
																			valueDate : Ext.util.Format.date(valueDate)
																		},
																		success : function(response) {
																			progBar.updateProgress((0.76), 'Query Pending Receipts...');
																			var recInsObj = Ext.decode(response.responseText);
																			pendingReceiptStore.removeAll();
																			var recInsArray = recInsObj.resultString.split(";");
																			var i;
																			for (i = 0; i < recInsArray.length; i++) {
																				if (recInsArray[i].replace(/^\s+|\s+$/g, '') != "") {
																					var recIns = recInsArray[i].split(',');
																					var recInsRec = Ext.create('PendingCashReq', {
																						reqNo : recIns[0],
																						amount : recIns[1],
																						reqDate : recIns[2]
																					});
																					pendingReceiptStore.add(recInsRec);
																				}
																			}
																			progBar.updateProgress((0.80), 'Query Pending Floating Rates..');
																			Ext.Ajax.request({
																				url : 'pendingFloatingRates.action',
																				params : {
																					queryOne : fundId,
																					valueDate : Ext.util.Format.date(valueDate)
																				},
																				success : function(response) {
																					progBar.updateProgress((0.84), 'Query Pending Floating Rates..');
																					var recInsObj = Ext.decode(response.responseText);
																					floatingRatePendingStore.removeAll();
																					var recInsArray = recInsObj.resultString.split(";");
																					var i;
																					for (i = 0; i < recInsArray.length; i++) {
																						if (recInsArray[i].replace(/^\s+|\s+$/g, '') != "") {
																							var recIns = recInsArray[i].split(',');
																							var recInsRec = Ext.create('FloatingRateInsrument', {
																								dealCode : recIns[0],
																								insType : recIns[1],
																								insCode : recIns[2],
																								issuer : recIns[3]
																							});
																							floatingRatePendingStore.add(recInsRec);
																						}
																					}
																					progBar.updateProgress((0.88), 'Query Collateral Pending REPOs...');
																					Ext.Ajax.request({
																						url : 'pendingCollaterals.action',
																						params : {
																							queryOne : fundId,
																							queryTwo : 'REPO',
																							valueDate : Ext.util.Format.date(valueDate)
																						},
																						success : function(response) {
																							progBar.updateProgress((0.92), 'Query Collateral Pending REPOs...');
																							var recInsObj = Ext.decode(response.responseText);
																							repoPendingCollatStore.removeAll();
																							var recInsArray = recInsObj.resultString.split(";");
																							var i;
																							for (i = 0; i < recInsArray.length; i++) {
																								if (recInsArray[i].replace(/^\s+|\s+$/g, '') != "") {
																									var recIns = recInsArray[i].split(',');
																									var recInsRec = Ext.create('PendingCollateral', {
																										dealCode : recIns[0],
																										dealValue : recIns[1],
																										issuer : recIns[2],
																										valueDate : recIns[3]
																									});
																									repoPendingCollatStore.add(recInsRec);
																								}
																							}
																							progBar.updateProgress((0.96), 'Query Collateral Pending Reverse REPOs...');
																							Ext.Ajax.request({
																								url : 'pendingCollaterals.action',
																								params : {
																									queryOne : fundId,
																									queryTwo : 'RREPO',
																									valueDate : Ext.util.Format.date(valueDate)
																								},
																								success : function(response) {
																									var recInsObj = Ext.decode(response.responseText);
																									revRepoPendingCollatStore.removeAll();
																									var recInsArray = recInsObj.resultString.split(";");
																									var i;
																									for (i = 0; i < recInsArray.length; i++) {
																										if (recInsArray[i].replace(/^\s+|\s+$/g, '') != "") {
																											var recIns = recInsArray[i].split(',');
																											var recInsRec = Ext.create('PendingCollateral', {
																												dealCode : recIns[0],
																												dealValue : recIns[1],
																												issuer : recIns[2],
																												valueDate : recIns[3]
																											});
																											revRepoPendingCollatStore.add(recInsRec);
																										}
																									}
																									progBar.updateProgress((1), 'Query Collateral Pending Reverse REPOs...');
																									Ext.ComponentQuery.query('#eodFundPanel')[0].setLoading(false);
																									progBar.updateText('Analyze Completed');
																								},
																								failure : function(response) {
																									Ext.Msg.alert('Error!', 'Failed to load Issuer Balances : ' + response);
																									Ext.ComponentQuery.query('#eodFundPanel')[0].setLoading(false);
																								}
																							});
																						},
																						failure : function(response) {
																							Ext.Msg.alert('Error!', 'Failed to load Issuer Balances : ' + response);
																							Ext.ComponentQuery.query('#eodFundPanel')[0].setLoading(false);
																						}
																					});
																				},
																				failure : function(response) {
																					Ext.Msg.alert('Error!', 'Failed to load Issuer Balances : ' + response);
																					Ext.ComponentQuery.query('#eodFundPanel')[0].setLoading(false);
																				}
																			});
																		},
																		failure : function(response) {
																			Ext.Msg.alert('Error!', 'Failed to load Issuer Balances : ' + response);
																			Ext.ComponentQuery.query('#eodFundPanel')[0].setLoading(false);
																		}
																	});
																},
																failure : function(response) {
																	Ext.Msg.alert('Error!', 'Failed to load Issuer Balances : ' + response);
																	Ext.ComponentQuery.query('#eodFundPanel')[0].setLoading(false);
																}
															});
														},
														failure : function(response) {
															Ext.Msg.alert('Error!', 'Failed to load Issuer Balances : ' + response);
															Ext.ComponentQuery.query('#eodFundPanel')[0].setLoading(false);
														}
													});
												},
												failure : function(response) {
													Ext.Msg.alert('Error!', 'Failed to load Issuer Balances : ' + response);
													Ext.ComponentQuery.query('#eodFundPanel')[0].setLoading(false);
												}
											});
										},
										failure : function(response) {
											Ext.Msg.alert('Error!', 'Failed to load Issuer Balances : ' + response);
											Ext.ComponentQuery.query('#eodFundPanel')[0].setLoading(false);
										}
									});
								},
								failure : function(response) {
									Ext.Msg.alert('Error!', 'Failed to load Issuer Balances : ' + response);
									Ext.ComponentQuery.query('#eodFundPanel')[0].setLoading(false);
								}
							});

						},
						failure : function(response) {
							Ext.Msg.alert('Error!', 'Failed to load Issuer Balances : ' + response);
							Ext.ComponentQuery.query('#eodFundPanel')[0].setLoading(false);
						}
					});

				},
				failure : function(response) {
					Ext.Msg.alert('Error!', 'Failed to load Issuer Balances : ' + response);
					Ext.ComponentQuery.query('#eodFundPanel')[0].setLoading(false);
				}
			});

		},
		failure : function(response) {
			Ext.Msg.alert('Error!', 'Failed to load Customer Balances : ' + response);
			Ext.ComponentQuery.query('#eodFundPanel')[0].setLoading(false);
		}
	});

};

EOD.getCenterPanel = function() {
	var filedset1 = EOD.getFieldSet1();
	var filedset2 = EOD.getFieldSet2();
	var filedset3 = EOD.getFieldSet3();

	var finalFormPanel = Ext.create('Ext.form.FormPanel', {
		bodyPadding : '20',
		autoScroll : true,
		frame : true,
		defaults : {
			labelWidth : 175,
			anchor : '65%'
		},
		fieldDefaults : {
			labelAlign : 'left',
			labelWidth : 150
		},
		title : 'End Of the Day Process',
		items : [ filedset1, filedset2, filedset3 ],
		buttons : [ {
			text : 'Reset',
			itemId : 'resetButton',
			handler : function() {
				Ext.ComponentQuery.query('#eodFundNameLbl')[0].setText(rec.get('fundName'));
				Ext.ComponentQuery.query('#eodFundBalLbl')[0].setText('Current Portfolio Value: ' + rec.get('portfolio'));
				Ext.ComponentQuery.query('#eodFundUnitValueLbl')[0].setText('Current Unit Value: ' + rec.get('unitValue'));
			}
		}, {
			text : 'Cancel',
			itemId : 'cancelButton'
		} ],
		listeners : {
			'afterrender' : {
				fn : function(thisField) {
					finalFormPanel.setLoading('Query Funds...');
					Ext.Ajax.request({
						url : 'getDayEndFunds.action',
						success : function(response) {
							var obj = Ext.decode(response.responseText);
							Ext.data.StoreManager.lookup('eodFundsStore').loadRawData(obj.fundList);
							finalFormPanel.setLoading(false);
						},
						failure : function() {
							finalFormPanel.setLoading(false);
							Ext.Msg.alert('Error', 'Failed to load Fund List');
						}
					});
				}
			}
		}
	});

	return finalFormPanel;
};
